import winsdk.windows.media.speechsynthesis as speechsynthesis
import winsdk.windows.media.playback as playback
import asyncio

async def speak_text_async(text_to_speak):
    synthesizer = speechsynthesis.SpeechSynthesizer()
    synthesizer.options.speaking_rate = 2
    stream = await synthesizer.synthesize_text_to_stream_async(text_to_speak)
    media_player = playback.MediaPlayer()
    media_player.set_stream_source(stream)
    media_player.play()
    while media_player.current_state != playback.MediaPlayerState.PAUSED:
        await asyncio.sleep(0.1)

if __name__ == '__main__':
    text_to_speak = '这是六倍速，满速朗读的效果，我相信一般没有经过训练的人，是听不清朗读内容的。'
    asyncio.run(speak_text_async(text_to_speak))